<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>大钞市·每天领钱</title>
    
    <link rel="stylesheet" href="css/index.css" />
    <script src="js/jquery-3.3.1.min.js"></script>
     <script src="js/config.js"></script>
    
</head>
<body>
	
		<header class="mui-bar mui-bar-nav">
		   <a href="/task/views/app/index.html">首页</a>
		</header>
	 
			   
	
	<script>

 
	var path = "/decorate";
	$(function () {
			 

			var channel = GetQueryString("channel")
			$.ajax({
				url : path + "/dk/start/h5.do",
				data : {
					channel : channel,
					version : "1"
				},
				type : "get",
				success : function(obj) {
					if (obj.respCode == 0) {
						setCookie("deviceToken", obj.data.deviceToken)
						setCookie("channel", channel)
					} else {

					}
				}
			})

		})

		function GetQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}
	
		function setCookie(name,value){
		    var Days = 30;
		    var exp = new Date();
		    exp.setTime(exp.getTime() + Days*24*60*60*1000);
		    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
		}

		function getCookie(name) {
		    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
		    if(arr=document.cookie.match(reg))
		        return unescape(arr[2]);
		    else
		        return null;
		}
		function clickCheckLogin(objval) {
			var url = $(objval).attr("href-url")
			checkLogin(url);
		}
		
		function checkLogin(url) {
			var token = getCookie("deviceToken");
			$.ajax({
				url : path + "/dk/check/login.do?deviceToken=" + token,
				type : "POST",
				success : function(obj) {
					if (obj.data.hasLogin == "true") {
						window.location.href = url
					} else if (obj.data.hasLogin == "false") {
						var loginUrl = "/dcs/h5/denglu.html?callbackPath="
								+ url;
						window.location.href = loginUrl;
					}
				}
			})
		}
	</script>
</body>
</html>